<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>首页</title>
		<script src="js/mui.min.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<link href="css/default.css" rel="stylesheet" />
		<style>
			
			
		</style>
	</head>

	<body>
		<nav class="mui-bar mui-bar-nav">
			<i class="icon iconfont icon-search mui-icon mui-pull-left"></i>
			<i class="icon iconfont icon-gengduo mui-icon mui-pull-right"></i>
			<i class="mui-icon-location mui-icon mui-pull-center"></i>
			<h1 id="title" class="mui-title">部落</h1>
		</nav>
		<div class="mui-content">
			
		</div>

		<script src="js/util.js"></script>
		<script type="text/javascript">
			(function() {
				mui.init({
					swipeBack: true //启用右滑关闭功能
				});
				//取消浏览器的所有事件，使得active的样式在手机上正常生效
				document.addEventListener('touchstart', function() {
					return false;
				}, true);
				// 禁止选择
				document.oncontextmenu = function() {
					return false;
				};

				mui.plusReady(function() {
					// 隐藏滚动条
					plus.webview.currentWebview().setStyle({
						scrollIndicator: 'none'
					});
					
					var self = plus.webview.currentWebview(),
						// 创建子webview窗口 并初始化
						aniShow = {};
					util.initSubpage(aniShow);

					var nviews = plus.nativeObj.View.getViewById('tabBar'),
						activePage = plus.webview.currentWebview(),
						targetPage,
						subpages = util.options.subpages,
						pageW = window.innerWidth,
						currIndex = 0;

					/**
					 * 根据判断view控件点击位置判断切换的tab
					 */
					nviews.addEventListener('click', function(e) {
						var clientX = e.clientX;
						if(clientX > 0 && clientX <= parseInt(pageW * 0.25)) {
							currIndex = 0;
						} else if(clientX > parseInt(pageW * 0.25) && clientX <= parseInt(pageW * 0.5)) {
							currIndex = 1;
						} else if(clientX > parseInt(pageW * 0.5) && clientX <= parseInt(pageW * 0.75)) {
							currIndex = 2;
						} else {
							currIndex = 3;
						}
						// 匹配对应tab窗口	
						if(currIndex > 0) {
							targetPage = plus.webview.getWebviewById(subpages[currIndex - 1]);
						} else {
							targetPage = plus.webview.currentWebview();
						}

						if(targetPage == activePage) {
							return;
						}

						//底部选项卡切换
						util.toggleNview(currIndex);
						// 子页面切换
						util.changeSubpage(targetPage, activePage, aniShow);
						//更新当前活跃的页面
						activePage = targetPage;

					});
				});
			})();
		</script>
	</body>

</html>